package gson.emlog.activity;

import org.json.simple.JSONArray;

import gson.emlog.R;
import gson.emlog.adapter.CloudTwittersAdapter;
import gson.emlog.utils.Action;
import gson.emlog.utils.Http;
import gson.emlog.utils.Result;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.ListView;

public class CloudTwitters extends Activity {
	private Context context;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		context = this;
		setContentView(R.layout.cloud_twitters);

		ListView lv = (ListView) findViewById(R.id.cloud_twitters_view);
		Toast.makeText(context, "加载中ing", Toast.LENGTH_SHORT).show();
		Http http = new Http(Action.CLOUD_TW);
		Result obj = http.post();
		JSONArray data = new JSONArray();
		if (obj.getStatus()) {
			data = (JSONArray) obj.getData();
		}else{
			Toast.makeText(context, obj.getData().toString(), Toast.LENGTH_SHORT).show();
		}
		CloudTwittersAdapter sadpt = new CloudTwittersAdapter(data, context);
		lv.setAdapter(sadpt);
		lv.setOnItemLongClickListener(new OnItemLongClickListener() {

			public boolean onItemLongClick(AdapterView<?> adv, View v,
					int item, long arg3) {
				return false;
			}
		});
	}
}
